package com.umgsai.thread.thread67;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyThread2 extends Thread {
    private String dateString;

    public MyThread2(String dateString) {
        super();
        this.dateString = dateString;
    }

    @Override
    public void run() {
        try {
            Date dateRef = DateUtil.parse("yyyy-MM-dd", dateString);
            String newDateString = DateUtil.format("yyyy-MM-dd" ,dateRef).toString();
            if (!newDateString.equals(dateString)) {
                System.out.println("ThreadName=" + this.getName()
                        +"报错了，日期字符串：" +dateString
                        +"，转换成的日期为："+newDateString);
            }else{
            	System.out.println("转换正确");
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args) {
        String[] dateStringArray = new String[]{"2016-07-01", "2016-07-02", "2016-07-03", "2016-07-04", "2016-07-05", "2016-07-06", "2016-07-07", "2016-07-08", "2016-07-09", "2016-07-10"};
        MyThread2[] threadArray = new MyThread2[10];
        for (int i=0; i<threadArray.length; i++) {
            threadArray[i] = new MyThread2(dateStringArray[i]);
        }
        for (int i=0; i<threadArray.length; i++) {
            threadArray[i].start();
        }
	}
}
